package com.jvm.栈内存溢出;

import java.util.ArrayList;
import java.util.List;

/*
    相互引用时，重写toString不当造成栈内存溢出
 */
public class 栈内存溢出2 {
    public static void main(String[] args) {
        Student stu = new Student("张三",29);
        Dept dept = new Dept("研发组");
        //开发人员集合
        List list = new ArrayList<Student>();
        list.add(stu);
        //互相赋值
        stu.setDept(dept);
        dept.setList(list);
        System.out.println(dept.getList());
    }
}
